package cn.stylefeng.guns.modular.controller;


import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.entity.Feedback;
import cn.stylefeng.guns.modular.entity.TaskDevice;
import cn.stylefeng.guns.modular.service.ITaskDeviceService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 任务设备表 前端控制器
 * </p>
 *
 * @author XiangTianGe
 * @since 2020-04-14
 */
@Controller
@RequestMapping("/task-device")
public class TaskDeviceController {


    @Autowired
    private ITaskDeviceService taskDeviceService;

    private static String PREFIX = "/task-device/";

    /**
     * 跳转报告首页
     */
    @RequestMapping
    public String index() {
        return PREFIX + "task_device.html";
    }


    /**
     * 获取报告列表
     */
    @ResponseBody
    @RequestMapping("list")
    public LayuiPageInfo list(String timeLimit, String keyword) {
        //获取分页参数
        Page<TaskDevice> page = LayuiPageFactory.defaultPage();


        //拼接查询条件
        String beginTime = null;
        String endTime = null;

        if (ToolUtil.isNotEmpty(timeLimit)) {
            String[] split = timeLimit.split(" - ");
            beginTime = split[0];
            endTime = split[1];
        }
        //根据条件查询日志
        return taskDeviceService.getList(page, beginTime, endTime, keyword);
    }
}

